package top.yzhao.trackdatasystem.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import top.yzhao.trackdatasystem.VO.ResultVO;
import top.yzhao.trackdatasystem.service.OtherService;

import java.util.List;

/**
 * User: zhaoyang
 * Date: 2020/3/13
 * Time: 16:46
 * Description: No Description
 */
@RestController
public class OtherController {
    @Autowired
    private OtherService otherService;

    @PostMapping("/getTables")
    public ResultVO<List> getTables(){
        ResultVO<List> res = new ResultVO<>();

        List<String> tablesList = otherService.getTables();
        res.setData(tablesList);
        res.setCode(200);
        res.setMsg("获取表名成功");
        return res;
    }

    @PostMapping("/getGc")
    public ResultVO<List> getGc(){
        ResultVO<List> res = new ResultVO<>();
        System.out.println("/getGc");
        List<String> gcList = otherService.getGc();
        res.setData(gcList);
        res.setCode(200);
        res.setMsg("获取数据成功");
        return res;
    }

    @PostMapping("/getAnomaly")
    public ResultVO<List> getAnomaly(){
        ResultVO<List> res = new ResultVO<>();

        List<String> anomalyList = otherService.getAnomaly();
        res.setData(anomalyList);
        res.setCode(200);
        res.setMsg("获取数据成功");
        return res;
    }

    @PostMapping("/getErrorMatrix")
    public ResultVO getErrorMatrix(int id){
        ResultVO res = new ResultVO<>();

        String[][] matrixList = otherService.getErrorMatrix(id);
        res.setData(matrixList);
        res.setCode(200);
        res.setMsg("获取数据成功");
        return res;
    }
}
